package prototype.autosurfer;

import java.io.IOException;
import java.net.URI;
import java.util.logging.Level;
import java.util.logging.Logger;

import net.m510.autosurfer.core.DocumentResponseHandler;
import net.m510.autosurfer.core.log.LogUtils;
import net.m510.autosurfer.core.process.AbstractSurfProcess;

import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.impl.client.CloseableHttpClient;
import org.jsoup.nodes.Document;

public class RootProcess extends AbstractSurfProcess {
	private static final Logger log = Logger.getLogger(RootProcess.class.getName());
	
	
	public RootProcess() {
	}
	public RootProcess(CloseableHttpClient cl, HttpClientContext ctx) {
		super(cl, ctx);
	}

	@Override
	public Document process(Document doc) throws ClientProtocolException, IOException {
		URI uri = URI.create("http://www.google.com");
//		HttpUriRequest req = RequestBuilder.get().setHeader("Content-type", "text/html; charset=UTF-8").setUri(uri).build();
		HttpGet req = new HttpGet(uri);
		ResponseHandler<Document> rh = new DocumentResponseHandler();
		Document out = client.execute(req,rh,context);
		LogUtils.logForms(log,Level.FINE,out.getAllElements().forms());
		return out;
	}

	
}
